package com.cskaoyan.gateway.controller.user;

import com.mall.commons.result.ResponseData;
import com.mall.commons.result.ResponseUtil;
import com.mall.user.IVerifyService;
import com.mall.user.annotation.Anoymous;
import com.mall.user.constants.SysRetCodeConstants;
import com.mall.user.dto.UserVerifyRequest;
import com.mall.user.dto.UserVerifyResponse;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description: 注册后激活模块
 * @author: enhui
 **/
@RestController
@RequestMapping("user")
public class VerifyController {
    @Reference
    IVerifyService verifyService;

    @GetMapping("verify")
    @Anoymous
    public ResponseData verify(String uid, String username) {
        UserVerifyRequest verifyRequest = new UserVerifyRequest();
        verifyRequest.setUserName(username);
        verifyRequest.setUuid(uid);
        UserVerifyResponse response = verifyService.verify(verifyRequest);
        if (SysRetCodeConstants.SUCCESS.getCode().equals(response.getCode())) {
            //成功
            return new ResponseUtil().setData(null);
        }
        return new ResponseUtil().setErrorMsg(response.getMsg());
    }
}
